using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class BK_BookingDetail
    {
        public int ID { get; set; }
        public int BookingID { get; set; }
        public int PassengerID { get; set; }
        public string FlightNo { get; set; }
        public string FromCity { get; set; }
        public string ToCity { get; set; }
        public int Price { get; set; }
        public DateTime StartDate { get; set; }
        public bool IsDeleted { get; set; }

        #region BK_BookingDetailSelectAll
        public static List<BK_BookingDetail> BK_BookingDetailSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_BookingDetail.BK_BookingDetailSelectAll(strSearch,top,bottom,ConnectionString);
            List<BK_BookingDetail> BK_BookingDetailList = new List<BK_BookingDetail>();
            while(dr.Read())
            {
                BK_BookingDetail myBK_BookingDetail = new BK_BookingDetail
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    BookingID = !dr.IsDBNull(dr.GetOrdinal("BookingID")) ? (int)dr["BookingID"] : 0,
                    PassengerID = !dr.IsDBNull(dr.GetOrdinal("PassengerID")) ? (int)dr["PassengerID"] : 0,
                    FlightNo = !dr.IsDBNull(dr.GetOrdinal("FlightNo")) ? (string)dr["FlightNo"] : null,
                    FromCity = !dr.IsDBNull(dr.GetOrdinal("FromCity")) ? (string)dr["FromCity"] : null,
                    ToCity = !dr.IsDBNull(dr.GetOrdinal("ToCity")) ? (string)dr["ToCity"] : null,
                    Price = !dr.IsDBNull(dr.GetOrdinal("Price")) ? (int)dr["Price"] : 0,
                    StartDate = !dr.IsDBNull(dr.GetOrdinal("StartDate")) ? (DateTime)dr["StartDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_BookingDetailList.Add(myBK_BookingDetail);
        }
        dr.Close();
        dr.Dispose();
        return BK_BookingDetailList;
        }
        #endregion
        #region BK_BookingDetailSelectRow
        public static BK_BookingDetail BK_BookingDetailSelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_BookingDetail.BK_BookingDetailSelectRow(ID, ConnectionString);
            BK_BookingDetail bk_bookingdetail = null;

            if(dr.Read())
            {
                bk_bookingdetail= new BK_BookingDetail
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    BookingID = !dr.IsDBNull(dr.GetOrdinal("BookingID")) ? (int)dr["BookingID"] : 0,
                    PassengerID = !dr.IsDBNull(dr.GetOrdinal("PassengerID")) ? (int)dr["PassengerID"] : 0,
                    FlightNo = !dr.IsDBNull(dr.GetOrdinal("FlightNo")) ? (string)dr["FlightNo"] : null,
                    FromCity = !dr.IsDBNull(dr.GetOrdinal("FromCity")) ? (string)dr["FromCity"] : null,
                    ToCity = !dr.IsDBNull(dr.GetOrdinal("ToCity")) ? (string)dr["ToCity"] : null,
                    Price = !dr.IsDBNull(dr.GetOrdinal("Price")) ? (int)dr["Price"] : 0,
                    StartDate = !dr.IsDBNull(dr.GetOrdinal("StartDate")) ? (DateTime)dr["StartDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return bk_bookingdetail;
        }
        #endregion

        #region BK_BookingDetailSelectRowByForeignKey_BookingID
        public static List<BK_BookingDetail> BK_BookingDetailSelectRowByForeignKey_BookingID(int BookingID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_BookingDetail.BK_BookingDetailSelectRowByForeignKey_BookingID(BookingID,ConnectionString);
            List<BK_BookingDetail> BK_BookingDetailList = new List<BK_BookingDetail>();
            while(dr.Read())
            {
                BK_BookingDetail myBK_BookingDetail = new BK_BookingDetail
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    BookingID = !dr.IsDBNull(dr.GetOrdinal("BookingID")) ? (int)dr["BookingID"] : 0,
                    PassengerID = !dr.IsDBNull(dr.GetOrdinal("PassengerID")) ? (int)dr["PassengerID"] : 0,
                    FlightNo = !dr.IsDBNull(dr.GetOrdinal("FlightNo")) ? (string)dr["FlightNo"] : null,
                    FromCity = !dr.IsDBNull(dr.GetOrdinal("FromCity")) ? (string)dr["FromCity"] : null,
                    ToCity = !dr.IsDBNull(dr.GetOrdinal("ToCity")) ? (string)dr["ToCity"] : null,
                    Price = !dr.IsDBNull(dr.GetOrdinal("Price")) ? (int)dr["Price"] : 0,
                    StartDate = !dr.IsDBNull(dr.GetOrdinal("StartDate")) ? (DateTime)dr["StartDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_BookingDetailList.Add(myBK_BookingDetail);
        }
        dr.Close();
        dr.Dispose();
        return BK_BookingDetailList;
        }
        #endregion

        #region BK_BookingDetailSelectRowByForeignKey_PassengerID
        public static List<BK_BookingDetail> BK_BookingDetailSelectRowByForeignKey_PassengerID(int PassengerID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_BookingDetail.BK_BookingDetailSelectRowByForeignKey_PassengerID(PassengerID,ConnectionString);
            List<BK_BookingDetail> BK_BookingDetailList = new List<BK_BookingDetail>();
            while(dr.Read())
            {
                BK_BookingDetail myBK_BookingDetail = new BK_BookingDetail
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    BookingID = !dr.IsDBNull(dr.GetOrdinal("BookingID")) ? (int)dr["BookingID"] : 0,
                    PassengerID = !dr.IsDBNull(dr.GetOrdinal("PassengerID")) ? (int)dr["PassengerID"] : 0,
                    FlightNo = !dr.IsDBNull(dr.GetOrdinal("FlightNo")) ? (string)dr["FlightNo"] : null,
                    FromCity = !dr.IsDBNull(dr.GetOrdinal("FromCity")) ? (string)dr["FromCity"] : null,
                    ToCity = !dr.IsDBNull(dr.GetOrdinal("ToCity")) ? (string)dr["ToCity"] : null,
                    Price = !dr.IsDBNull(dr.GetOrdinal("Price")) ? (int)dr["Price"] : 0,
                    StartDate = !dr.IsDBNull(dr.GetOrdinal("StartDate")) ? (DateTime)dr["StartDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_BookingDetailList.Add(myBK_BookingDetail);
        }
        dr.Close();
        dr.Dispose();
        return BK_BookingDetailList;
        }
        #endregion

        #region BK_BookingDetailSelectRowByForeignKey_BookingID_PassengerID
        public static List<BK_BookingDetail> BK_BookingDetailSelectRowByForeignKey_BookingID_PassengerID(int BookingID,int Passenger, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_BookingDetail.BK_BookingDetailSelectRowByForeignKey_BookingID_PassengerID(BookingID,Passenger, ConnectionString);
            List<BK_BookingDetail> BK_BookingDetailList = new List<BK_BookingDetail>();
            while(dr.Read())
            {
                BK_BookingDetail myBK_BookingDetail = new BK_BookingDetail
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    BookingID = !dr.IsDBNull(dr.GetOrdinal("BookingID")) ? (int)dr["BookingID"] : 0,
                    PassengerID = !dr.IsDBNull(dr.GetOrdinal("PassengerID")) ? (int)dr["PassengerID"] : 0,
                    FlightNo = !dr.IsDBNull(dr.GetOrdinal("FlightNo")) ? (string)dr["FlightNo"] : null,
                    FromCity = !dr.IsDBNull(dr.GetOrdinal("FromCity")) ? (string)dr["FromCity"] : null,
                    ToCity = !dr.IsDBNull(dr.GetOrdinal("ToCity")) ? (string)dr["ToCity"] : null,
                    Price = !dr.IsDBNull(dr.GetOrdinal("Price")) ? (int)dr["Price"] : 0,
                    StartDate = !dr.IsDBNull(dr.GetOrdinal("StartDate")) ? (DateTime)dr["StartDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_BookingDetailList.Add(myBK_BookingDetail);
        }
        dr.Close();
        dr.Dispose();
        return BK_BookingDetailList;
        }
        #endregion
        #region BK_BookingDetailInsertRow
        public static void BK_BookingDetailInsertRow(int ID, int BookingID, int PassengerID, string FlightNo, string FromCity, string ToCity, int Price, DateTime StartDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_BookingDetail.BK_BookingDetailInsertRow(ID, BookingID, PassengerID, FlightNo, FromCity, ToCity, Price, StartDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_BookingDetailUpdateRow
        public static void BK_BookingDetailUpdateRow(int ID, int BookingID, int PassengerID, string FlightNo, string FromCity, string ToCity, int Price, DateTime StartDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_BookingDetail.BK_BookingDetailUpdateRow(ID, BookingID, PassengerID, FlightNo, FromCity, ToCity, Price, StartDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_BookingDetailDeleteRow
        public static void BK_BookingDetailDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_BookingDetail.BK_BookingDetailDeleteRow(ID,ConnectionString);
        }
        #endregion
    }
}
